<template>
  <div class="line">
    <p class="line_title">未来30天游客量趋势图</p>
    <p class="line_bg"></p>
    <div class="line_charts" ref="charts"></div>
  </div>
</template>

<script setup lang='ts'>
import * as echarts from 'echarts'
import { onMounted, ref } from 'vue';
// 获取数据dom元素
let charts = ref()
onMounted(() => {
  let mycharts = echarts.init(charts.value)
  mycharts.setOption({
    // backgroundColor: '#1b1d21',
    legend: {
      icon: "circle",
      fontSize: 14,
      color: "rgba(255,255,255,.8)",
      data: [{
        name: "",
        itemStyle: {
          color: "#2ca8ff"
        }
      }, {
        name: "",
        itemStyle: {
          color: "#81e279"
        }
      }]
    },
    grid: {
      top: "23%",
      left: "2%",
      right: "3%",
      bottom: "22 %",
      containLabel: true,
    },
    tooltip: {
      trigger: "axis",
      backgroundColor: "transparent",
      axisPointer: {
        lineStyle: {
          color: "#3763cd", //显示竖线颜色
          type: "solid",
        },
      },
      textStyle: {
        color: "#ffffff"
      }
    },
    xAxis: [
      {
        boundaryGap: false,
        type: "category",
        axisLine: {
          //坐标轴轴线相关设置。数学上的x轴
          show: false,
          lineStyle: {
            color: "#485051",
          },
        },

        axisLabel: {
          show: true,
          interval: 0,
          color: "#fff",
          padding: 10,
          fontSize: 14,

        },
        axisTick: {
          show: false,
        },
        data: [
          '05/05',
          '05/07',
          '05/09',
          '05/11',
          '05/13',
          '05/15',
          '05/17',
          '05/19',
          '05/21',
          '05/23',
          '05/25',
          '05/27'
        ],
      },
    ],
    yAxis: [
      {
        name: "访问量",
        splitLine: {
          lineStyle: {
            color: "#485051",
          },
        },
        axisLine: {
          show: true,

        },
        axisLabel: {
          show: true,
          color: "#ffffff",
          padding: 10,
          fontSize: 14,
        },
        axisTick: {
          show: false,
        },

      },
    ],
    series: [
      {
        name: '游客访问量',
        type: "line",
        smooth: true,
        showSymbol: false,
        lineStyle: {
          width: 2,
          color: "#81e279", // 线条颜色
        },

        areaStyle: {
          color: new echarts.graphic.LinearGradient(
            0,
            0,
            0,
            1,
            [
              {
                offset: 0,
                color: "rgba(131,225,175,0.5)",
              },
              {
                offset: 1,
                color: "rgba(131,225,175,0)",
              },
            ],
            false
          ),



        },
        data: [
          3000, 2500, 4640, 4356, 5900, 6000, 3400, 5640, 5640, 3690, 6480, 15858
        ],
      },

    ],
  })
})

</script>

<style scoped lang="scss">
.line {
  height: 300px;
  background: url(../../../images/dataScreen-main-lb.png) no-repeat;
  background-size: 100% 100%;
  margin: 0 40px;

  .line_title {
    font-size: 20px;
    color: white;
  }

  .line_bg {
    width: 68px;
    height: 7px;
    margin-top: 10px;
    background: url(../../../images/dataScreen-title.png) no-repeat;

  }

  .line_charts {
    height: 200px;
  }
}
</style>